package com.niiwoo.civet.mobile.service.bill.detail;

import com.alibaba.fastjson.JSON;
import com.niiwoo.civet.account.dto.response.NiiwooBillRespDTO;
import com.niiwoo.civet.account.dto.response.UserBillBaseResponseDTO;
import com.niiwoo.civet.account.enums.BillStatusEnum;
import com.niiwoo.civet.account.enums.OrderTypeEnum;
import com.niiwoo.civet.mobile.vo.response.bill.JumpTypeEnum;
import com.niiwoo.civet.mobile.vo.response.bill.UserBillDetailResponse;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 退款账单说情
 * Created by Yijian on 2018/11/9.
 */
@Service
public class RefundBillDetailStrategyImpl implements BillDetailStrategy {

    @Override
    public String build(UserBillBaseResponseDTO userBillBase, List<NiiwooBillRespDTO> userBillFlowList, UserBillDetailResponse response) {

        //特殊处理状态(应产品的要求退款账单的状态全都显示为成功)
        response.setStatus(BillStatusEnum.SUCCESS.getValue());
        response.setStatusDesc(BillStatusEnum.getEnumByCode(response.getStatus()).getDesc());

        //退款说明
        UserBillDetailResponse.SpecialItem specialItem = response.new SpecialItem();
        specialItem.setName("退款说明");
        String content = OrderTypeEnum.enumOf(userBillBase.getOrderType()).getDesc() + "失败退回";
        specialItem.setContent(content);
        specialItem.setIsNeedJump(Boolean.TRUE);
        specialItem.setJumpType(JumpTypeEnum.BILL_DETAIL.getCode());
        specialItem.setJumpParamOne(userBillBase.getBackSourceBillId().toString());//资金回退的源账单id
        response.getSpecialItems().add(specialItem);
        return JSON.toJSONString(response);
    }
}
